package com.zjj.lbw.ai;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ai.chat.client.advisor.api.AdvisedRequest;
import org.springframework.ai.chat.client.advisor.api.AdvisedResponse;
import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisor;
import org.springframework.ai.chat.client.advisor.api.CallAroundAdvisorChain;

public class ZjjCallAroundAdvisor implements CallAroundAdvisor {

    private static final Logger logger = LoggerFactory.getLogger(ZjjCallAroundAdvisor.class);

    @Override
    public AdvisedResponse aroundCall(AdvisedRequest advisedRequest, CallAroundAdvisorChain chain) {

        logger.info("BEFORE: {}", advisedRequest);

        AdvisedRequest advisedRequest1 = AdvisedRequest.from(advisedRequest).systemText("请给我写一首七言绝句").build();

        AdvisedResponse advisedResponse = chain.nextAroundCall(advisedRequest1);

        logger.info("AFTER: {}", advisedResponse);

        return advisedResponse;
    }

    @Override
    public String getName() {
        return this.getClass().getSimpleName();
    }

    @Override
    public int getOrder() {
        // 数字越小，越先执行，升序排序
        return 0;
    }
}
